<!DOCTYPE html>
<html>
<head>
	<title>餐饮营销支持系统</title>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="../../css/bootstrap.min.css" rel="stylesheet">
	<!-- <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"> -->
	<link rel="stylesheet" type="text/css" href="../../css/waiter.css">
</head>
<body>
	<div id="head">
		<div class="navbar navbar-default  navbar-inverse" role="navigation">
			<div class="navbar-header">
				<a href="##" class="navbar-brand">餐饮营销支持系统</a>
			</div>
			<button type="submit" class="btn btn-danger">
				<span style="margin-right: 5px" class="glyphicon glyphicon-off"></span>注销
			</button>
		</div>
	</div>
	
	<div id="left">
		<p class="left-head">
		boss登录</p>
		<div class="container">
			<div class="row" style="margin-top: 0px">
				<a href="./boss.html">
					<div class="col-md-12">
						<span class="glyphicon glyphicon-user"></span>
						<p>个人信息</p>
					</div>
				</a>
			</div>
			<div class="row act">

				<div class="col-md-12">
					<span class="glyphicon glyphicon-home"></span>
					<p>店铺管理</p>
				</div>

			</div>
			<div class="row">
				<a href="./boss-three.html">
					<div class="col-md-12">
						<span class="glyphicon glyphicon-plus-sign"></span>
						<p>店铺人员</p>
					</div>
				</a>
			</div>
			<div class="row">
				<a href="./boss-four.html">
					<div class="col-md-12">
						<span class="glyphicon glyphicon-list"></span>
						<p>菜单管理</p>
					</div>
				</a>
			</div>
			<div class="row">
				<a href="./boss-five.html">
					<div class="col-md-12">
						<span class="glyphicon glyphicon-retweet"></span>
						<p>收益比例</p>
					</div>
				</a>
			</div>

			<div class="row">
				<a href="./boss-six.html">
					<div class="col-md-12">
						<span class="glyphicon glyphicon-th"></span>
						<p>收入查询</p>
					</div>
				</a>
			</div>
		</div>
	</div>

	<div id="right">
		<div class="right-head">
			<ol class="breadcrumb">
				<li><a href="#">首页</a></li>
				<li><a href="boss-two.html">店铺数据详情</a></li>
				<li class="active">店铺添加</li>
			</ol> 
		</div>
		<div class="con">
			<div class="container">
				<div class="row">
					<div class="col-md-12">
						<div class="panel panel-default">
							<div class="panel-body">
								<div class="row">
									<p class="from-top">
										店铺添加
									</p>
								</div>
								<form class="form-horizontal" method="get" data-validate="parsley">
									<div class="form-group">
										<label class="col-lg-3 control-label">
											店铺名称：
										</label>
										<div class="col-lg-8">
											<input type="text" name="shop-name" placeholder="请输入店铺名称" class="bg-focus form-control parsley-validated" id="strorename" >
										</div>
									</div>

									<div class="form-group" style="margin-bottom: 0;padding-bottom: 20px">
										<label class="col-lg-3 control-label">
											地区：
										</label>
										<div class="col-lg-2">
											<select name="省" class="form-control" id = "provinces"> 
											</select>
										</div>
										<div class="col-lg-2">
											<select name="市" class="form-control" id = "citys"> 
											</select>
										</div>
										<div class="col-lg-2">
											<select name="县" class="form-control" id = "adress"> 
											</select>
										</div>
										<div class="col-lg-1">
											<button type='button' class='btn btn-primary' id="add-adress">新添</button>
										</div>
									</div>
									<div id="new-adress" style="margin-top: -20px">
										<div class="form-group">
											<div class="col-lg-2 col-lg-offset-3">
												<input type="text" name="manager-name" placeholder="省" class="bg-focus form-control parsley-validated" id = "n-provinces"> 
											</div>
											<div class="col-lg-2">
												<input type="text" name="manager-name" placeholder="市" class="bg-focus form-control parsley-validated" id = "n-citys"> 
											</div>
											<div class="col-lg-2">
												<input type="text" name="manager-name" placeholder="县" class="bg-focus form-control parsley-validated" id = "n-adress"> 
											</div>
											<div class="col-lg-1">
												<button type='button' class='btn btn-primary' id="d-adress">确定</button>
											</div>
										</div>
									</div>
									<hr style="margin-top: 0">
									<div class="form-group">
										<p class="col-lg-12">
											店铺经理信息录入
										</p>
									</div>

									<div class="form-group">
										<label class="col-lg-3 control-label">
											姓名：
										</label>
										<div class="col-lg-8">
											<input type="text" name="manager-name" placeholder="请输入真实姓名" class="bg-focus form-control parsley-validated" id="managername" >
										</div>
									</div>

									<div class="form-group">
										<label class="col-lg-3 control-label">
											身份证号：
										</label>
										<div class="col-lg-8">
											<input type="text" name="manager-identity" placeholder="请输入身份证号" class="bg-focus form-control parsley-validated" id="manageridcard" >
										</div>
									</div>

									<div class="form-group">
										<label class="col-lg-3 control-label">
											手机号：
										</label>
										<div class="col-lg-8">
											<input type="text" name="manager-phone" placeholder="请输入手机号" class="bg-focus form-control parsley-validated" id="managertel" >
										</div>
									</div>

									<div class="form-group">
										<label class="col-lg-3 control-label">
											密码：
										</label>
										<div class="col-lg-8">
											<input type="password" name="manager-password" placeholder="请输入密码" class="bg-focus form-control parsley-validated" id="pwd" >
										</div>
									</div>

									<div class="form-group">
										<label class="col-lg-3 control-label">
											确定密码：
										</label>
										<div class="col-lg-8">
											<input type="password" name="manager-bpassword" placeholder="请再次输入密码" class="bg-focus form-control parsley-validated" data-required="true" data-type="email" id="repwd">
										</div>
									</div>
									<div class="form-group">
										<div class="col-lg-2 col-lg-offset-5">
											<button class="btn btn-danger" type="reset">重 置</button>
											<button style="margin-left: 15px" class="btn btn-primary" type="button" id="shop-submit">提 交</button>  
										</div>
									</div>
								</form>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<script src="../../js/Jquary/jquery-3.2.1.min.js"></script>
	<script src="../../js/Jquary/jquery.easyui.min.js"></script>
	<script src="../../js/bootstrap.min.js"></script>
	<script type="text/javascript" src="../../js/logout.js"></script>
	<script type="text/javascript" src="../../js/adress.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
				$("#shop-submit").click(function(){//添加店铺
					var adressid = $("#adress").val();
					if(adressid==-1){
						alert("无效的地区")
						return;
					}
					var strorename = $("#strorename").val();
					if(strorename==""){
						alert("请输入店铺名称")
						return;
					}
					var managername = $("#managername").val();
					if(managername==""){
						alert("请输入经理姓名")
						return;
					}
					var manageridcard = $("#manageridcard").val();
					if(manageridcard==""){
						alert("请输入经理身份证号")
						return;
					}
					var managertel = $("#managertel").val();
					if(managertel==""){
						alert("请输入经理电话号")
						return;
					}
					var pwd = $("#pwd").val();
					var repwd = $("#repwd").val();
					if(pwd==null){
						alert("请输入密码")
						return;
					}
					if(pwd!=repwd){
						alert("两次输入密码不一致")
						return;
					}
					addStore(adressid,strorename,managername,manageridcard,managertel,pwd)
				});
				$("#add-adress").click(function(){
					showOrHiden();
				});
				$("#d-adress").click(function(){
					var n_provinces = $("#n-provinces").val();
					if(n_provinces==""){
						alert("请输入省")
						return;
					}
					var n_citys = $("#n-citys").val();
					if(n_citys==""){
						alert("请输入市")
						return;
					}
					var n_adress = $("#n-adress").val();
					if(n_adress==""){
						alert("请输入县")
						return;
					}
					addAdress(n_provinces,n_citys,n_adress);
				})

				getAdress();
				
			})
		</script>
		<script type="text/javascript">
			function addAdress(pname,cname,aname){
				$.ajax({
					type:"get",
					url:"/ldss/address/add",
					data:{
						pname:pname,
						cname:cname,
						aname:aname
					},
					async:false,
					dataType:"json",
					success: function (data) {
						if(data.success){
							var data = data;
							alert(data.message);
							getAdress();
							showOrHiden();
						}else{
							alert(data.message);
							showOrHiden();
						}
					}
				});
			}
			function addStore(adressid,strorename,managername,manageridcard,managertel,pwd){
				$.ajax({
					type:"get",
					url:"/ldss/store/add",
					data:{
						storename:strorename,
						adressid:adressid,
						realname:managername,
						usertel:managertel,
						userIDcard:manageridcard,
						userpsswd:pwd
					},
					dataType:"json",
					success: function (data) {
						if(data.success){
							var data = data;
							window.location.href="./boss-two.html";
						}else{
							alert(data.message);
						}
					}
				});
			}
			function showOrHiden(){
				if ($("#new-adress").css("display")=="none") {
					$("#new-adress").slideToggle();
					$("#provinces").attr("disabled",'')
					$("#citys").attr("disabled",'')
					$("#adress").attr("disabled",'')
				}else{
					$("#new-adress").slideToggle();
					$("#provinces").removeAttr("disabled",'')
					$("#citys").removeAttr("disabled",'')
					$("#adress").removeAttr("disabled",'')
				}
			}
		</script>
	</body>
	</html>